// 
// Decompiled by Procyon v0.5.36
// 

package com.orange.boot.dev1.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.orange.boot.dev1.entity.DetailUrl;
import java.io.IOException;
import org.springframework.web.bind.annotation.GetMapping;
import io.swagger.annotations.ApiOperation;
import com.orange.boot.utils.R;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.orange.boot.dev1.service.NewsService;
import org.springframework.web.bind.annotation.CrossOrigin;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/dev1/news"})
@Api(
        tags = {"动态资讯接口"}
)
@CrossOrigin
public class NewsController {
    @Autowired
    NewsService newsService;

    public NewsController() {
    }

    @ApiOperation("写死的固定新闻")
    @GetMapping({"{count}"})
    public R getNews(@PathVariable("count") Integer count) {
        return this.newsService.getNews(count);
    }

    @ApiOperation("爬虫爬取的新闻,最大页数9页， page取值1-9，表示1-9页")
    @GetMapping({"paChong/{page}"})
    public R paChong(@PathVariable("page") Integer page) {
        return this.newsService.paChong(page);
    }

    @ApiOperation("爬虫爬取的新网站的新闻,最大页数9页， page取值1-9，表示1-9页")
    @GetMapping({"newPaChong/{page}"})
    public R newPaChong(@PathVariable("page") Integer page) throws IOException {
        System.out.println("爬虫方法被调用");

        try {
            return this.newsService.newPaChong(page);
        } catch (IOException var3) {
            throw new RuntimeException(var3);
        }
    }

    @ApiOperation("根据详情页的url返回详情页信息")
    @PostMapping({"detail"})
    public R detail(@RequestBody DetailUrl detailUrl) {
        return this.newsService.detail(detailUrl);
    }
}

